//
//  UITextField+AddToolBar.m
//  MZB
//
//  Created by 吴文拼 on 2017/11/28.
//  Copyright © 2017年 吴文拼. All rights reserved.
//

#import "UITextField+AddToolBar.h"
#import "DCFNormalView.h"
@implementation UITextField (AddToolBar)

-(void)addNormalToolBar{
    DCFNormalView *toolbar = [[DCFNormalView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
    toolbar.backgroundColor = RGBCOLOR(250, 250, 250);
    DCFNormalLabel *centerLab = [[DCFNormalLabel alloc] init];
    [centerLab set_dcf_textAligment:NSTextAlignmentCenter];
    [centerLab set_dcf_font:[UIFont systemFontOfSize:14]];
    [centerLab set_dcf_textColor:RGBCOLOR(102, 102, 102)];
    centerLab.text = @"已开启安全键盘";
    [toolbar addSubview:centerLab];
    [centerLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(toolbar);
        make.centerX.equalTo(toolbar).offset(13);
        make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(100, 20)]);
    }];
    DCFNormalImageView *imV = [[DCFNormalImageView alloc] init];
    [imV set_dcf_image:[UIImage imageNamed:@"keyboard_toolbar_safe"]];
    [toolbar addSubview:imV];
    [imV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(toolbar);
        make.right.equalTo(centerLab.mas_left).offset(-10);
        make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(16, 18.3)]);
    }];
    DCFNormalLabel *confirmBtn = [[DCFNormalLabel alloc] init];
    [confirmBtn set_dcf_textAligment:NSTextAlignmentCenter];
    [confirmBtn set_dcf_font:[UIFont systemFontOfSize:14]];
    [confirmBtn set_dcf_textColor:RGBCOLOR(90, 141, 255)];
    confirmBtn.text = @"完成";
    confirmBtn.userInteractionEnabled = YES;
    [confirmBtn set_dcf_EnlargeEdgeWithTop:10 right:20 bottom:10 left:20];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(textFieldDone)];
    [confirmBtn addGestureRecognizer:tap];
    [toolbar addSubview:confirmBtn];
    [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(toolbar);
        make.right.equalTo(toolbar).offset(-10);
        make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(30, 20)]);
    }];
    self.inputAccessoryView = toolbar;
}

-(void)textFieldDone{
    [self endEditing:YES];
}

@end
